<?
include"../inc/config.inc.php";
if($_POST[MODE]=="ADD")
{
    $gbook_id=$_POST['gbook_id'];
    $gbook_name=$_POST['gbook_name'];
    $gbook_detail=$_POST['gbook_detail'];
    $gbook_date=$_POST['gbook_date'];

    if(empty($gbook_name)
            || empty($gbook_detail))
    {
        echo"<meta http-equiv='refresh' content='0;URL=../user/guestbook.php'>";
        exit;
    }
    else
    {
        $sql = "insert into guestbook(gbook_id, gbook_name, gbook_detail, gbook_date) values("
              ."'$gbook_id', '$gbook_name', '$gbook_detail', '$gbook_date')";
        mysql_query($sql) or die (mysql_error());
        echo"<meta http-equiv='refresh' content='0;URL=../user/guestbook.php'>";
    }

    
}
if($_GET[MODE]=="DEL")
{
    $gbook_id=$_GET['gbook_id'];
    $gbook_name=$_GET['gbook_name'];
    $gbook_detail=$_GET['gbook_detail'];
    $gbook_date=$_GET['gbook_date'];
    $sql="delete from guestbook where gbook_id='$gbook_id'";
    mysql_query($sql) or die (mysql_error());
    echo"<meta http-equiv='refresh' content='0;URL=gbook.php'>";
}
if($_POST[MODE]=="EDIT")
{
    $gbook_id=$_POST['gbook_id'];
    $gbook_name=$_POST['gbook_name'];
    $gbook_detail=$_POST['gbook_detail'];
    $gbook_date=$_POST['gbook_date'];
    $sql="UPDATE guestbook set gbook_id='$gbook_id',gbook_name='$gbook_name',gbook_detail='$gbook_detail',gbook_date='$gbook_date'";
    mysql_query($sql) or die (mysql_error());
    echo"<meta http-equiv='refresh' content='0;URL=../user/guestbook.php'>";
}
?>